﻿using System;
using System.Collections.Generic;
using System.Data.Entity;
using System.Linq;
using System.Text;

namespace AlmKickstart.Data
{
	public class AlmKickstartEntities : DbContext
	{
		public DbSet<Project> Projects { get; set; }
		public DbSet<ProjectType> ProjectTypes { get; set; }
		public DbSet<Status> ProjectStatuses { get; set; }

		protected override void OnModelCreating(DbModelBuilder modelBuilder)
		{
			base.OnModelCreating(modelBuilder);
			modelBuilder.Entity<Project>()
				.HasOptional(e => e.ParentProject)
				.WithMany()
				.HasForeignKey(m => m.ParentProjectId);

			modelBuilder.Entity<ProjectType>()
				.HasOptional(e => e.ParentProjectType)
				.WithMany()
				.HasForeignKey(m => m.ParentProjectTypeId);
		}
	}
}
